import Types from '../actionTypes';

let initState = {
  selectKey: '',
  data: [{
    label: '一级 1',
    key: '1',
    children: [{
      label: '二级 1-1',
      key: '1-1',
      children: [{
        label: '三级 1-1-1',
        key: '1-1-1'
      }]
    }]
  }],
  infoData: {}
};

export default (state = initState, action) => {

  const newState = JSON.parse(JSON.stringify(state));

  switch (action.type) {
    case Types.SELECT_KEY:
      newState.selectKey = action.value;
      return newState;
    case Types.MARTERIAL_GROUP_DATA:
      newState.data = action.value;
      return newState;
    case Types.GET_MAMARTERIAL_GROUP_INFO:
      newState.infoData = action.value;
      return newState;
    default:
      console.log('Types no match in MaterialGroup.js ....');
  }

  return state;
}
